package com.freeze.demo.blockchain;

import java.io.Serializable;
import java.util.List;

/**
 * <p>Title: Block</p>
 * <p>Description: </p>
 * @author he_jiebing@jiuyv.com
   @date   2021年4月9日 上午11:20:54
 */

public class Block implements Serializable{
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	
	private int index;
	
	private long timestamp;
	
	private long proof;
	
	private String previousHash;
	
	private List<Transaction> transactions;
	
	

	public Block() {
		super();
	}
	
	

	public Block(int index, long timestamp, long proof, String previousHash,
			List<Transaction> transactions) {
		super();
		this.index = index;
		this.timestamp = timestamp;
		this.proof = proof;
		this.previousHash = previousHash;
		this.transactions = transactions;
	}

	@Override
	public String toString() {
		// Review: String Concat
		return "Block(\nindex: "
		.concat(Integer.toString(this.index))
		.concat("\n, ")
		.concat("timestamp:")
		.concat(Long.toString(this.timestamp))
		.concat("\n, ")
		.concat("proof:")
		.concat(Long.toString(this.proof))
		.concat("\n, ")
		.concat("prevHash:")
		.concat(this.previousHash)
		// TODO: handle Transactions 
		.concat("\n, ")
		.concat("txs:")
		.concat(this.transactions.toString())
		.concat(")");
		// "\ntimestamp: " + this.timestamp
	}	


	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public long getProof() {
		return proof;
	}

	public void setProof(long proof) {
		this.proof = proof;
	}

	public String getPreviousHash() {
		return previousHash;
	}

	public void setPreviousHash(String previousHash) {
		this.previousHash = previousHash;
	}

	public List<Transaction> getTransactions() {
		return transactions;
	}

	public void setTransactions(List<Transaction> transactions) {
		this.transactions = transactions;
	}
	
	

}
